package com.xs.designpattern;

import lombok.Getter;
import lombok.Setter;

/**
 * @author xs
 */
@Getter
@Setter
public class Kingdom {
    private King king;
    private Castle castle;
    private Army army;

    /**
     * 王国工厂的工厂
     */
    public static class FactoryMaker {

        /**
         * 不同类型王国的枚举
         */
        public enum KingdomType {
            ELF, ORC
        }

        /**
         * 创建 KingdomFactory 具体对象的工厂方法
         */
        public static KingdomFactory makeFactory(KingdomType type) {
            if (type == KingdomType.ELF) {
                return new ElfKingdomFactory();
            } else if (type == KingdomType.ORC) {
                return new OrcKingdomFactory();
            } else {
                throw new IllegalArgumentException("KingdomType不支持！");
            }
        }
    }
}
